package engine.systems.ui.button
{
	import ash.core.Component;
	import ash.core.Entity;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	public class Button extends Component
	{
		internal var _invalidate:Boolean 	= false;
		internal var _isDown:Boolean 		= false;
		internal var _isOver:Boolean 		= false;
		internal var _isOut:Boolean 		= false;
		
		public var locked:Boolean;
		
		public var value:*;
		public var prefix:String;
		public var animated:Boolean;
		
		public function Button(value:* = null, prefix:String = "", animated:Boolean = false, locked:Boolean = false)
		{
			this.value 		= value;
			this.prefix		= prefix;
			this.animated 	= animated;
			this.locked 	= locked;
		}
		
		override public function destroy():void
		{
			this.value = null;
		}
		
		public function down(entity:Entity = null, event:MouseEvent = null):void
		{
			if(this.locked) return;
		
			this._invalidate 	= true;
			this._isDown 		= true;
		}
		
		public function over(entity:Entity = null, event:MouseEvent = null):void
		{
			if(this.locked) return;
			
			this._invalidate 	= true;
			this._isOver 		= true;
		}
		
		public function out(entity:Entity = null, event:MouseEvent = null):void
		{
			if(this.locked) return;
			
			this._invalidate 	= true;
			this._isOut 		= true;
		}
	}
}